package com.css.zfzx.sjcj.modules.hddcGeoProfileLine.repository;

import com.css.zfzx.sjcj.modules.hddcGeoProfileLine.repository.entity.HddcGeoprofilelineEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zhangcong
 * @date 2020-11-30
 */
public interface HddcGeoprofilelineRepository extends JpaRepository<HddcGeoprofilelineEntity, String> {

    @Query(nativeQuery = true, value = "select * from hddc_Geoprofileline where project_name in :projectIds")
    List<HddcGeoprofilelineEntity> queryHddcGeoprofilelinesByProjectId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_Geoprofileline where is_valid = '1'")
    List<HddcGeoprofilelineEntity> findAll();

    @Query(nativeQuery = true, value = "select * from hddc_Geoprofileline where task_name in :projectIds")
    List<HddcGeoprofilelineEntity> queryHddcGeoprofilelinesByTaskId(List<String> projectIds);

    @Query(nativeQuery = true, value = "select * from hddc_Geoprofileline where create_user = :createID and province = :provinceName and city =:cityName and area =:areaName")
    List<HddcGeoprofilelineEntity> queryHddcGeoprofilelineByCreateuser(String createID, String provinceName, String cityName, String areaName);

    @Modifying
    @Query(nativeQuery = true, value = "update hddc_Geoprofileline set is_valid = '0' where province = :provinceName and city =:cityName and area =:areaName and extends8 =:savefilename")
    void deleteFileData(String provinceName, String cityName, String areaName, String savefilename);
}
